<?php
$dsn="mysql:Server=127.0.0.1;dbname=blog";
$db= new PDO($dsn, "root", "123456");
$db ->exec("set names utf8mb4");

$addTime =time();
$updateTime =$addTime;

$sql ="update admin set admin_id='$adminId',admin_email='$adminEmail',admin_name='$adminName',admin_password='admin_password',update_time='$updateTime' 
        where admin_id='$adminId'";
$result =$db->exec($sql);

if (mb_strlen($adminName) < 2 || mb_strlen($adminName) > 50) {
    echo '姓名限制2~50个字';
    echo '<a href="javascript:void(0)" onclick="history.back();">返回上一页</a>';
    exit();
}
// 10~100
if (mb_strlen($adminEmail) < 1 || mb_strlen($adminEmail) > 100) {
    echo '邮箱限制1~100个字';
    echo '<a href="javascript:void(0)" onclick="history.back();">返回上一页</a>';
    exit();
}
// 密码又修改则需要校验
if ($adminPassword && $adminPassword2) {
    // 10~8000
    if (mb_strlen($adminPassword) < 6 || mb_strlen($adminPassword) > 50) {
        echo '密码长度6~20。';
        echo '<a href="javascript:void(0)" onclick="history.back();">返回上一页</a>';
        exit();
    }
    if ($adminPassword !== $adminPassword2) {
        echo '两次密码输入不一致。';
        echo '<a href="javascript:void(0)" onclick="history.back();">返回上一页</a>';
        exit();
    }
}